
********************************************************************************
*
* Title:	FOREIGN TRAINING, COURSE CONTENT, AND POLITICAL MILITARIZATION
*
* Authors: 	Adam Scharpf and Jesse D. Savage
*
* Journal:	World Politics
*
* Date:		June 2024
*
********************************************************************************
*
* Content:	Replication of results in the manuscript and supporting information
*
*			Steps:
*			1) Set working directory below ("Setting working directory in macro")
*			2) Run do-file
*			3) Replicate results and figures
*
********************************************************************************
*
* Packages: Before running this code, please make sure you have the following
*			.ado-files installed
*
*			- Parmest Package, Version 2
*					net install st0043_2.pkg
*
*			- Labmask Package
*					net install gr0034.pkg
*
********************************************************************************

	version 16.0
	set more off

	clear all
 
 
********************************************************************************
*
* Setting working directory in macro
*
********************************************************************************

	*Insert path to folder containing replication datasets before running
	//Example: "C:\Users\me\Desktop\ScharpfSavage_WP_ForeignTraining"
	global path="..."
	
 
********************************************************************************
*
* Producing log-file of results
*
********************************************************************************

	*Start recording log file
	log using "$path\replication_log", replace
	
	
********************************************************************************
*
* Figures in manuscript
*
********************************************************************************	
	
	****************************************************************************
	*Figure 1. Training at the School of the Americas.
	****************************************************************************	
	
	*Loading micro replication dataset 
	use "$path\replication_data_micro.dta", clear
	
	
	***********************************	
	*Figure 1. (a)
	***********************************	
	
	*Preserving data
	preserve
	
	*Collapsing data 
	collapse (sum) soaGEN, by(ranktypecl)
	
	*Generating variable on overall course count
	egen ctotal=total(soaGEN) 
	
	*Calculating shares in %
	gen perc=(soaGEN/ctotal)*100
	
	*Graph
	#delimit ;
	twoway (dropline perc ranktypecl if ranktypecl<=5, horizontal mcolor(black) lcolor(black) lwidth(*0.75))
		   ,
			ysize(1)
			xsize(1.4)			
			xscale(range(0 50) noextend titlegap(*+5))
			yscale(range(0.5 5.5) noextend titlegap(*+7))
			xlabel(0(10)50)
			ylabel( 1 "Enlisted" 
					2 `" "Noncommissioned" "officer" "' 
					3 `" "Company grade" "officer" "' 
					4 `" "Field grade" "officer" "' 
					5 `" "General" "officer" "'
					,
					nogrid
					 angle(horizontal)
			)
			xtick(, tlength(*0.5))			
			xtitle("Percentage of courses attended")
			ytitle("")
			graphregion(color(white) lcolor(white) lalign(outside)  margin(l=15 r=15)) 			
			legend(off)
			;
	#delimit cr		
	graph export "$path\figure_1_a.tif", as(tif) replace width(1500)
		
	*Preserving data
	restore		
	
	
	***********************************	
	*Figure 1. (b)
	***********************************		
	
	*Calculating course duration
	gen clength_days= cend_day - cstart_day
		
	*Standardizing by months
	gen clength_month=clength_days/30
		
	*Graph
	#delimit ;
	twoway (kdensity clength_days if soaNOCOINWARS==1, lcolor(gs8) lpattern(shortdash) bwidth(3) kernel(gaussian) range(0 365)) //bwidth(.3)
		   (kdensity clength_days if soaCOIN==1, lcolor(black) lpattern(solid) bwidth(3) kernel(gaussian) range(0 365)) //bwidth(1)
		   ,
		   xsize(1.2) ysize(1) 
		   xscale(range(0 365) noextend titlegap(+2))
		   yscale(range() noextend titlegap(+1))
 	       ylabel(, nogrid angle(0) labsize(*.85)) 
		   xlabel(0(30)365, angle(horizontal) nogrid labsize(*.85))
		   xtitle("Course length (in days)", size(*.85))
		   ytitle("Kernel density", size(*.85))
		   legend(order(
					2 "Counterinsurgency courses" 				 
					1 "Conventional warfare courses"				 
					)					
					col(1)
					size(*.75) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(lcolor(black))
					position(2) ring(0) bmargin(2 0 0 6)
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			;
	#delimit cr	
	graph export "$path\figure_1_b.tif", as(tif) replace width(1500)

	
	****************************************************************************
	*Figure 2. Distribution of dependent variable, 1949-1969.	
	****************************************************************************		
	
	*Loading macro replication dataset
	use "$path\replication_data_macro.dta", clear
	
	*Preserving data
	preserve
	
	*Identifying country-years with highest and lowest militarization score 
	sum milcont_dynamic if cuba_win_ind==1
	groups countryname year milcont_dynamic if cuba_win_ind==1 & (milcont_dynamic==r(max) | milcont_dynamic==r(min))		
	
	*Identifying highest score
	sum milcont_dynamic if cuba_win_ind==1	
	local milconarg=r(max)
	disp `milconarg'
	
	*Identifying lowest score	
	sum milcont_dynamic if cuba_win_ind==1
	local milconcor=r(min)
	disp `milconcor'		
		
	*Identifying values for Argentina and Costa Rica
	gen milcont_argentina=milcont_dynamic if cuba_win_ind==1 & gwno==160 & milcont_dynamic==float(`milconarg')
	gen milcont_costarica=milcont_dynamic if cuba_win_ind==1 & gwno==94  & milcont_dynamic==float(`milconcor')
	
	*Generating y-value
	gen yvalue=-0.01
	
	*Graph
	#delimit ;	
	twoway (kdensity milcont_dynamic if cuba_win_ind==1, kernel(gaussian) bwidth(0.2) lcolor(black))
		   (scatter yvalue milcont_argentina, msymbol(T) mfcolor(black) mlwidth(0) msize(*1.5))
		   (scatter yvalue milcont_costarica, msymbol(O) mfcolor(black) mlwidth(0) msize(*1.4))	
			,
			ysize(1)
			xsize(1.25)
			yscale(range() noextend titlegap(+2))
			xscale(range() noextend titlegap(+2))		   
			ylabel(, angle(horizontal) nogrid)
			xlabel()
			title("")
			note("")
			ytitle("Density")
			xtitle("{&larr} Less				 						More {&rarr}" "Military involvement in politics")
			legend(
				order(2 "Argentina (1969)" 3 "Costa Rica (1969)")
				size(*.8) keygap(*0.5) symxsize(*.5) symysize(*.5) region(lcolor(black))
				cols(1) 
				 bmargin(2 0 5 0)
				position(2) ring(0)			
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			; 
	#delimit cr		
	graph export "$path\figure_2.tif", as(tif) replace width(1500)
	
	*Restoring data
	restore
	
	
	****************************************************************************
	*Figure 3. Attendances across course types.
	****************************************************************************		
	
	***********************************	
	*Figure 3. (a)
	***********************************		
	
	*Preserving data
	preserve
	
	*Keeping data in observation window
	keep if cuba_win_ind==1
	
	*Generating variables on courses in post-revolution window (i.e., year>=1959)
	gen post_soaCOIN = soaCOIN if cuba_postwin_ind==1 
	gen post_soaNOCOINWARS = soaNOCOINWARS if cuba_postwin_ind==1 	
	
	*Aggregating training data and military control by country 
	#delimit ;
	collapse (sum) soaGEN soaCOIN soaNOCOINWARS post_soaCOIN post_soaNOCOINWARS 
			 (first) countryname 
			 , 
			 by(gwno)
			; 
	#delimit cr		
	
	*Generating course shares
	gen coinshare = (soaCOIN / soaGEN) * 100
	gen convshare = (soaNOCOINWARS / soaGEN) * 100 	
	gen coinconvshare = (soaCOIN / soaNOCOINWARS) * 100 
		
	*Inverting training in conventional warfare for plotting	
	gen convshare_neg = convshare * (-1)
	gen soaNOCOINWARS_neg = soaNOCOINWARS * (-1)
	
	*Generating y-axis
	sort soaCOIN
	gen yaxis=_n-1
	labmask yaxis, val(countryname)
	
	*Graph
	#delimit ;
	twoway (bar soaNOCOINWARS_neg yaxis, horizontal lcolor(black) fcolor(gs14) barwidth(0.9))
		   (bar soaCOIN yaxis, horizontal lcolor(black) fcolor(gs4) barwidth(0.9)) 
			,
			ysize(1)
			xsize(1.25)
			yscale(range(0 18) noextend titlegap(+2))
			xscale(range(-4000 2000) noextend titlegap(+2))		   
			ylabel(0(1)18, valuelabel angle(horizontal) nogrid)
			xlabel(-3000 "3,000" -2000 "2,000" -1000 "1,000" 0 "0" 1000 "1,000" 2000 "2,000" 3000 "3,000")	
			ytitle("")
			xtitle("  	   Number of courses")
			legend(
				order( 1 "Conventional warfare" 2 "Counterinsurgency" )
				size(*.9) keygap(*0.5) symxsize(*.5) symysize(*.5) region(lcolor(black))
				cols(2)
				position(6) 
				bmargin(0 0 0 2) 
			
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			; 
	#delimit cr	
	graph export "$path\figure_3_a.tif", as(tif) replace width(1500)

	
	***********************************	
	*Figure 3. (b)
	***********************************		
	
	*Generating y-axis
	sort coinconvshare
	gen yaxis_cshare=_n-1	
	labmask yaxis_cshare, val(countryname)	
	
	*Graph
	#delimit ;
	twoway (bar coinconvshare yaxis_cshare, horizontal lcolor(black) fcolor(gs4) barwidth(0.8)) 
			,
			ysize(1)
			xsize(1.25)
			yscale(range(0 18) noextend titlegap(+2))
			xscale(range(0 50) noextend titlegap(+2))		   
			ylabel(0(1)18, valuelabel angle(horizontal) nogrid)
			xlabel()	
			ytitle("")
			xtitle("Relative share of counterinsurgency courses (%)")
			legend(off
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			; 
	#delimit cr	
	graph export "$path\figure_3_b.tif", as(tif) replace width(1500)
	
	*Preserving data
	restore	
	
	
	****************************************************************************
	*Figure 4. Course attendances across countries and over time.
	****************************************************************************	

	***********************************	
	*Figure 4. (a)
	***********************************		
	
	*Graph
	#delimit ;
	twoway (bar soaCOIN cuba_win if cuba_win_ind==1, 
							fcolor(gs12) lcolor(gs5) lwidth(0.1) 
							)
		   (lpoly soaCOIN cuba_win if cuba_win_ind==1, 
							lpattern(solid) lcolor(black) lwidth(*2.25)    
							bwidth(1) kernel(gaussian))
		   , 
		   by(country,
		   		//yrescale 
				graphregion(color(white) lcolor(white) lalign(outside))				
				legend(at(20) pos(0))
				note("")
				)			
		   xline(0, lcolor(gs5) lwidth(*1) lpattern(dot))
		   subtitle(, lcolor(black) fcolor(gs14) size(*1) margin(t=1.25))			
		   yscale( noextend titlegap(*+10))
		   xscale(range(-12 12) noextend titlegap(*+10)) 
		   ylabel(#3, angle(0) nogrid labsize(*1.3))			
		   xlabel(-10(5)10, labsize(*1.3))
		   xticks(, tlength(*.5))
		   ytitle("Number of counterinsurgency courses", size(*.7))
		   xtitle("Years before and after Cuban Revolution (1959)", size(*.7))
		   legend(order(
						1 "Raw number"
						2 "Smoothed number"
						)					
					col(1)
					size(*1) 			
					keygap(*1) 
					symxsize(*1) 
					symysize(*1) 
					region(lcolor(white))
			)		   	   
			;
	#delimit cr	
	graph export "$path\figure_4_a.tif", as(tif) replace width(1500)
		

	***********************************	
	*Figure 4. (b)
	***********************************	
	
	*Graph	
	#delimit ;
	twoway (bar soaNOCOINWARS cuba_win if cuba_win_ind==1, 
							fcolor(gs12) lcolor(gs5) lwidth(0.1) 
							)
		   (lpoly soaNOCOINWARS cuba_win if cuba_win_ind==1, 
							lpattern(solid) lcolor(black) lwidth(*2.25)  
							bwidth(1) kernel(gaussian))
		   , 
		   by(country,
		   		//yrescale 
				graphregion(color(white) lcolor(white) lalign(outside))				
				legend(at(20) pos(0))
				note("")
				)			
		   xline(0, lcolor(gs5) lwidth(*1) lpattern(dot))
		   subtitle(, lcolor(black) fcolor(gs14) size(*1) margin(t=1.25))			
		   yscale( noextend titlegap(*+10))
		   xscale(range(-12 12) noextend titlegap(*+10)) 
		   ylabel(#3, angle(0) nogrid labsize(*1.3))			
		   xlabel(-10(5)10, labsize(*1.3))
		   xticks(, tlength(*.5))
		   ytitle("Number of conventional warfare courses", size(*.7))
		   xtitle("Years before and after Cuban Revolution (1959)", size(*.7))
		   legend(order(
						1 "Raw number"
						2 "Smoothed number"
						)					
					col(1)
					size(*1) 			
					keygap(*1) 
					symxsize(*1) 
					symysize(*1) 
					region(lcolor(white))
			)		      
			;
	#delimit cr	
	graph export "$path\figure_4_b.tif", as(tif) replace width(1500)
	
	
	****************************************************************************
	*Figure 5. Marginal effects of course types on militarization. 
	****************************************************************************	
	
	*Calculating and exporting marginal effects
	#delimit ;
		
	//Storing model in local
	local model_m1="reg milcont_dynamic 
				    ln_l1_soaCOIN 
					ln_l1_soaNOCOINWARS 
					l1_gdpgrowth
					llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					ln_yrscoup 	 
				    i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_m1';	
	
	//Assessing empirical coverage
	sum ln_l1_soaCOIN ln_l1_soaNOCOINWARS if e(sample)==1	;
		
	//Running model
	quiet `model_m1' ;
	
	//Calculating marginal effects: Counterinsurgency courses
	margins, 
		at((asobserved) _all ln_l1_soaCOIN=(0(.1)5))
		expression(predict(xb)) 
		post;
	parmest, saving("$path\figure5_margins_coin.dta", replace) level(90 95) idstr("llnsoaCOIN");	
	
	//Running model
	quiet `model_m1';
	
	//Calculating marginal effects: Conventional warfare courses
	margins, 
		at((asobserved) _all ln_l1_soaNOCOINWARS=(0(.1)5))
		expression(predict(xb)) 
		post;
	parmest, saving("$path\figure5_margins_conv.dta", replace) level(90 95) idstr("llnsoaNOCOINWARS");			
	
	#delimit cr	

	*Preserving data
	preserve	
	
	*Loading and appending exported effects datasets 
	clear	
	use "$path\figure5_margins_coin.dta"
	append using "$path\figure5_margins_conv.dta"

	*Reshaping data
	gen id="_coin" if regexm(idstr, "soaCOIN")
	replace id="_nocoin" if regexm(idstr, "soaNOCOINWARS") & id==""
	
	gen panel=regexs(0) if regexm(parm,"^[0-9]+")
	destring panel, replace
	keep estimate min* max* panel id
	reshape wide estimate min* max*, i(panel) j(id) string
	
	*Generating x-axes
	gen xaxis=(_n-1)*0.1 in 1/51
	gen xaxis_coin=xaxis-0.02
	gen xaxis_nocoin=xaxis+0.02
	
	*Graph
	#delimit ;		
	twoway line estimate_nocoin xaxis_nocoin,
					 lcolor(gs8) lwidth(*.9)				 				 
		  || rspike min95_nocoin max95_nocoin xaxis_nocoin,
					 lcolor(gs8) lwidth(*1.15)
		  || scatter estimate_nocoin xaxis_nocoin,
					 msymbol(o) msize(*.65) mfcolor(white) mlcolor(gs8) mlwidth(*.8) mlalign(outside)				 
		  || line estimate_coin xaxis_coin,
					 lcolor(black) lwidth(*.9)						 
		  || rspike min95_coin max95_coin xaxis_coin,
					 lcolor(black) lwidth(*1.15)				 
		  || scatter estimate_coin xaxis_coin,
					 mcolor(black) msize(*.65) lcolor(black)				
				 xsize(1.2) ysize(1) 
				 xscale(range() noextend titlegap(+1))
				 yscale(range() noextend titlegap(+1))
 	             ylabel( , valuelabel nogrid angle(0) labsize(*.85)) 
				 xlabel(0(1)5, angle(horizontal) nogrid labsize(*.85))
				 xtitle("Number of courses attended (logged)", size(*.85))
				 ytitle("Military involvement in politics" "{&larr} Less		 					More {&rarr}", size(*.85))
				 legend(order(
						6 "Counterinsurgency courses" 				 
						3 "Conventional warfare courses"				 
						)					
					col(1)
					size(*.75) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(lcolor(black))
					position(11) ring(0) bmargin(2 0 0 6)
					)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			; 
	#delimit cr		
	graph export "$path\figure_5.tif", as(tif) replace width(1500)	
	
	*Restoring data
	restore	
	
	
	****************************************************************************
	*Figure 6. Counterinsurgency course content over time.
	****************************************************************************	
	
	*Loading micro replication dataset 
	use "$path\replication_data_micro.dta", clear
				
	*Collapsing data
	collapse (sum) cnum, by(cointopic_agg starty)
	drop if cointopic==.
	
	*Reshaping data
	reshape wide cnum, i(starty) j(cointopic_agg)
		
	*Adding startyear 1949
    local new = _N + 1
    set obs `new'
	replace starty=1949 if starty==.
	
	*Completing time series
	tsset starty, yearly
	tsfill
		
	foreach var of varlist cnum* {
		replace `var'=0 if `var'==.		
	}
	
	*Generating cumulative sums for plotting
	rename cnum1 milintel
	egen irregularwar=rowtotal(milintel cnum2)
	egen statebuilding=rowtotal(irregularwar cnum3)
	
	*Graph
	#delimit ;
	twoway bar statebuilding starty, barwidth(.5) lcolor(black) fcolor(black) lwidth(0)
	||	   bar irregularwar starty, barwidth(.5) lcolor(gs5) fcolor(gs5) lwidth(0)
	||	   bar milintel starty, barwidth(.5) lcolor(gs10) fcolor(gs10) lwidth(0)
				 ,
				 xsize(1.25) ysize(1) 
				 xscale(range(1949 1969) noextend titlegap(+2))
				 yscale(range(0 500) noextend titlegap(+2))
 	             ylabel(0(100)500, valuelabel nogrid angle(0) labsize(*1)) 
				 xlabel(1949(2)1969, angle(horizontal) nogrid labsize(*1))
				 xtick(1949(1)1969, tlength(*.5))
				 xtitle("Year", size(*1))
				 ytitle("Number of courses", size(*1))
				 xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))
				 legend(order(
						1 "State-building" 				 
						2 "Irregular warfare"				 
						3 "Intelligence"
						)					
					col(1)
					size(*.85) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(lcolor(black))
					position(11) ring(0) bmargin(2 0 0 2)
					)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			; 
	#delimit cr	
	graph export "$path\figure_6.tif", as(tif) replace width(1500)	
	
	
	****************************************************************************
	*Figure 7. Effects of counterinsurgency course content.
	****************************************************************************		

	*Loading macro replication dataset
	use "$path\replication_data_macro.dta", clear	
	
	*Calculating and exporting marginal effects
	#delimit ;
				
	//Storing model 1 in local
	local model_robc14m1="reg milcont_dynamic 
				    c.ln_l1_soaCOIN_milintel
					c.ln_l1_soaNOCOINWARS
					c.l1_gdpgrowth
					c.llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					c.ln_yrscoup 	 
					i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_robc14m1';		
	
	//Calculating marginal effects: Intelligence courses
		margins, 
		dydx(ln_l1_soaCOIN_milintel)
		at((asobserved) _all)
		expression(predict(xb)) 
		post;
	parmest, saving("$path\figure7_margins_intel.dta", replace) level(95) idstr("milintel");			

	//Storing model 2 in local
	local model_robc14m2="reg milcont_dynamic 
				    c.ln_l1_soaCOIN_irregularwar
					c.ln_l1_soaNOCOINWARS
					c.l1_gdpgrowth
					c.llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					c.ln_yrscoup 	 
					i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_robc14m2';		
	
	//Calculating marginal effects: Irregular warfare
		margins, 
		dydx(ln_l1_soaCOIN_irregularwar)
		at((asobserved) _all)
		expression(predict(xb)) 
		post;
	parmest, saving("$path\figure7_margins_irregwar.dta", replace) level(95) idstr("irregularwar");			
	
	//Storing model 3 in local
	local model_robc14m3="reg milcont_dynamic 
				    c.ln_l1_soaCOIN_statebuilding
					c.ln_l1_soaNOCOINWARS
					c.l1_gdpgrowth
					c.llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					c.ln_yrscoup 	 
					i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_robc14m3';		
	
	//Calculating marginal effects: State-building
		margins, 
		dydx(ln_l1_soaCOIN_statebuilding)
		at((asobserved) _all)
		expression(predict(xb)) 
		post;
	parmest, saving("$path\figure7_margins_statebuild.dta", replace) level(95) idstr("statebuilding");			
	
	#delimit cr		
		
	*Preserving data
	preserve	
	
	*Loading and appending exported effects datasets 
	clear	
	use "$path\figure7_margins_intel.dta"	
	append using "$path\figure7_margins_irregwar.dta"
	append using "$path\figure7_margins_statebuild.dta"
	
	*Generating x-axis
	gen xaxis=.
	replace xaxis=1 if regexm(parm,"milintel")
	replace xaxis=2 if regexm(parm,"irregular")
	replace xaxis=3 if regexm(parm,"statebuilding")	
	
	*Graph
	#delimit ;
	twoway (rspike min95 max95 xaxis, lcolor(black) lwidth(*1))
		   (connected estimate xaxis, lcolor(black) lpattern(shortdash) color(black) msize(*1.25)) 	
			,
			ysize(1)
			xsize(1)			
			yscale(range(-.1 .5) noextend titlegap(*+5))
			xscale(range(0.75 2.25) noextend titlegap(*+5))
			ylabel(-.1(.1).5, angle(horizontal) nogrid labgap(+1.5))
			xlabel(
				   1 "Intelligence" 
				   2 `" "Irregular" "warfare" "'
				   3 `" "State-" "building" "'
				   , 
			)
			ytitle("Marginal effect on" "military involvement in politics")
			xtitle(" ")
			yline(0, lpattern(dot) lcolor(black))
			graphregion(color(white) lcolor(white) lalign(outside) margin(l=15 r=15)) 			
			legend(off)
		   ;
	#delimit cr		
	graph export "$path\figure_7.tif", as(tif) replace width(1500)		
	
	*Restoring data
	restore	
	
	
	****************************************************************************
	*Figure 8. Content dissemination.
	****************************************************************************			

	***********************************	
	*Figure 8. (a)
	***********************************		
	
	*Calculating and exporting marginal effects
	#delimit ;
				
	//Storing model in local
	local model_robc19m6="reg milcont_dynamic 
				    c.ln_l1_soaCOIN##c.lnumacad 
				    c.ln_l1_soaNOCOINWARS##c.lnumacad 
					c.l1_gdpgrowth
					c.llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					c.ln_yrscoup 	 
					i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_robc19m6';	
	
	//Number of academies
	tab lnumacad if e(sample)==1;
	
	//Calculating marginal effects: Counterinsurgency courses across military academies
	margins, 
		dydx(ln_l1_soaCOIN)
		at((asobserved) _all lnumacad=(0(1)4))
		expression(predict(xb)) 
		post ;
	parmest, saving("$path\figure8_margins_coin_acad.dta", replace) level(90 95) idstr("llnsoaCOIN");			
	
	//Running model
	`model_robc19m6';	
			
	//Calculating marginal effects: Conventional warfare courses across military academies
	margins, 
		dydx(ln_l1_soaNOCOINWARS)
		at((asobserved) _all lnumacad=(0(1)4))
		expression(predict(xb)) 
		post ;
	parmest, saving("$path\figure8_margins_conv_acad.dta", replace) level(90 95) idstr("llnsoaNOCOINWARS");			
	#delimit cr			
			
	*Preserving data
	preserve	
	
	*Loading and appending exported effects datasets 
	clear	
	use "$path\figure8_margins_coin_acad.dta"
	append using "$path\figure8_margins_conv_acad.dta"
	
	*Reshaping data
	gen id=0 if regexm(idstr, "soaCOIN")
	replace id=1 if regexm(idstr, "soaNOCOINWARS") & id==.
	
	gen panel=regexs(0) if regexm(parm,"^[0-9]+")
	destring panel, replace
	replace panel=panel-1
	keep estimate min* max* panel id
		
	*Generating x-axis 
	sort panel id
	gen xaxis=.
	replace xaxis=panel-0.1 if id==0
	replace xaxis=panel+0.1 if id==1

	*Graph			
	#delimit ;		
	twoway rspike min95 max95 xaxis if id==0,
					 lcolor(black) lwidth(*1.75)
		  || rspike min95 max95 xaxis if id==1,
					 lcolor(gs8) lwidth(*1.75)
		  || connected estimate xaxis if id==1,
					 lcolor(gs8) lpattern(shortdash) mlcolor(gs8) mlwidth(.7) mfcolor(white) msize(*.6) mlalign(outside)					 
		  || connected estimate xaxis if id==0,
					 lcolor(black) lpattern(shortdash) color(black) msize(*1.6)					 
				 xsize(1.2) ysize(1) 
				 xscale(range(-0.5 +4.5) noextend titlegap(+2))
				 yscale(range() noextend titlegap(0))
 	             ylabel(-.4(.2).4, nogrid angle(0) labsize(*1)) 
				 xlabel(0(1)4, angle(horizontal) nogrid labsize(*1))
				 xtitle("Number of military academies", size(*1) color(black))
				 ytitle("Marginal effect on" "military involvement in politics", size(*1) )	
				 yline(0, lpattern(dot) lcolor(black))
				 legend(off)	
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	 
			; 
	#delimit cr		
	graph export "$path\figure_8_a.tif", as(tif) replace width(1500)
	
	*Restoring data
	restore		


	***********************************	
	*Figure 8. (b)
	***********************************			
	
	*Calculating and exporting marginal effects
	#delimit ;
				
	//Storing model in local
	local model_robc19m12="reg milcont_dynamic 
				    c.ln_l1_soaCOIN##c.lperdcls 
				    c.ln_l1_soaNOCOINWARS##c.lperdcls 
					c.l1_gdpgrowth
					c.llntroopqual 				
					i.lguerrillad 				
					i.lstrikesd 					
					i.ldemond
 					i.lriotsd
					i.ldmiddispforcetoward 			
					c.ln_yrscoup 	 
					i.c2
					i.c3
					i.c4
					i.c5
					i.c6
					i.c7
					i.c8
					i.c9
					i.c10
					i.c11
					i.c12
					i.c13
					i.c14
					i.c15
					i.c16
					i.c17
					i.c18
					i.c19
				   , robust	
					"
	;

	//Running model
	`model_robc19m12';	
	
	//Number of military periodicals
	tab lperdcls if e(sample)==1;
	
	//Calculating marginal effects: Counterinsurgency courses across military periodicals
	margins, 
		dydx(ln_l1_soaCOIN)
		at((asobserved) _all lperdcls=(0(2)8))
		expression(predict(xb)) 
		post ;
	parmest, saving("$path\figure8_margins_coin_peri.dta", replace) level(90 95) idstr("llnsoaCOIN");			
	
	//Running model
	`model_robc19m12';	
			
	//Calculating marginal effects: Conventional warfare courses across military periodicals
	margins, 
		dydx(ln_l1_soaNOCOINWARS)
		at((asobserved) _all lperdcls=(0(2)8))
		expression(predict(xb)) 
		post ;
	parmest, saving("$path\figure8_margins_conv_peri.dta", replace) level(90 95) idstr("llnsoaNOCOINWARS");			
	#delimit cr			
			
	*Preserving data
	preserve	
	
	*Loading and appending exported effects datasets 
	clear	
	use "$path\figure8_margins_coin_peri.dta"
	append using "$path\figure8_margins_conv_peri.dta"
	
	*Reshaping data
	gen id=0 if regexm(idstr, "soaCOIN")
	replace id=1 if regexm(idstr, "soaNOCOINWARS") & id==.
	
	gen panel=regexs(0) if regexm(parm,"^[0-9]+")
	destring panel, replace
	replace panel=panel-1
	keep estimate min* max* panel id
		
	*Generating x-axis 
	sort panel id
	gen xaxis=.
	replace xaxis=panel-0.1 if id==0
	replace xaxis=panel+0.1 if id==1

	*Graph
	#delimit ;		
	twoway rspike min95 max95 xaxis if id==0,
					 lcolor(black) lwidth(*1.75)
		  || rspike min95 max95 xaxis if id==1,
					 lcolor(gs8) lwidth(*1.75)
		  || connected estimate xaxis if id==1,
					 lcolor(gs8) lpattern(shortdash) mlcolor(gs8) mlwidth(.7) mfcolor(white) msize(*.6) mlalign(outside)					 
		  || connected estimate xaxis if id==0,
					 lcolor(black) lpattern(shortdash) color(black) msize(*1.6)					 
				 xsize(1.2) ysize(1) 
				 xscale(range(-0.5 +4.5) noextend titlegap(+2))
				 yscale(range() noextend titlegap(0))
 	             ylabel(-.4(.2).4, nogrid angle(0) labsize(*1)) 
				 xlabel(0 "0" 1 "2" 2 "4" 3 "6" 4 "8", angle(horizontal) nogrid labsize(*1))
				 xtitle("Number of military periodicals", size(*1) color(black))
				 ytitle("Marginal effect on" "military involvement in politics", size(*1) )	
				 yline(0, lpattern(dot) lcolor(black))
				 legend(order(	
						4 "Counterinsurgency courses"
						3 "Conventional warfare courses"
					)					
					col(1)
					size(*1) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.35) 
					region(lcolor(black))
					position(5) ring(0) bmargin(0 11.5 2 0))	
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	 
			; 
	#delimit cr		
	graph export "$path\figure_8_b.tif", as(tif) replace width(1500)	
	
	*Restoring data
	restore			

	
	****************************************************************************
	*Figure 9. Temporal developments among Batista allies (treatment group) and other countries (control group) over time.
	****************************************************************************		

	*Preserving data
	preserve
	
	*Collapsing data	
	collapse (mean) milcont_dynamic SOAshare_coingen, by(cubaally_high_treatg year)
		
	*Dropping observations outside of analysis window
	drop if cubaally_high_treatg==.		
	
	
	***********************************	
	*Figure 9. (a)
	***********************************			

	*Graph
	#delimit ;
	twoway (connected SOAshare_coingen year if cubaally_high_treatg==0, lwidth(*1.1) mlcolor(black) mfcolor(white) lpattern(shortdash) lcolor(black))
		   (connected SOAshare_coingen year if cubaally_high_treatg==1, lwidth(*1.1) mcolor(back) lpattern(solid) lcolor(black)) 
		   , 
		   ysize(1)
		   xsize(1.2)
		   xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))    	
		   xscale(range(1949 1969) noextend) 
		   xlabel(1949(5)1969)
		   xticks(1949(1)1969, tlength(*.5))
		   xtitle("Year", size(*1))	
		   yscale(range() noextend)
		   ylabel(#6, nogrid angle(0) labsize(*1)) 		 	   
		   ytitle("Share of counterinsurgency courses", size(*1))		   
		   legend(off	
		)
		plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
		;
	#delimit cr
	graph export "$path\figure_9_a.tif", as(tif) replace width(1500)
	
	
	***********************************	
	*Figure 9. (b)
	***********************************		

	*Graph
	#delimit ;
	twoway (connected milcont_dynamic year if cubaally_high_treatg==0, lwidth(*1.1) mlcolor(black) mfcolor(white) lpattern(shortdash) lcolor(black))
		   (connected milcont_dynamic year if cubaally_high_treatg==1, lwidth(*1.1) mcolor(back) lpattern(solid) lcolor(black)) 
		   , 
		   ysize(1)
		   xsize(1.2)
		   xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))  	
		   xscale(range(1949 1969) noextend) 
		   xlabel(1949(5)1969)
		   xticks(1949(1)1969, tlength(*.5))
		   xtitle("Year", size(*1))	
		   yscale(range(0 1) noextend titlegap(0))
		   ylabel(1(.2)0, nogrid angle(0) labsize(*1)) 		 	   
		   ytitle("Military involvement in politics", size(*1))		   
		   legend( 	
					order(2 "Treatment group" 1 "Control group") 	
					rows(2)	
					size(*.8) 			
					keygap(*0.75) 
					symxsize(*0.4) 
					symysize(*0.5) 
					region(lcolor(black))
					position(7) ring(0) bmargin(2.2 0 2 0)		
		)
		plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
		;
	#delimit cr
	graph export "$path\figure_9_b.tif", as(tif) replace width(1500)	
	
	*Restoring data
	restore	
	
	
	****************************************************************************
	*Figure 10. Delayed militarization effect after Cuban Revolution among Batista allies.
	****************************************************************************			
	
	*Storing control variables in macros
	#delimit ;
	global did_controls="
					gdpgrowth
					lntroopqual 				
					guerrillad 				
					strikesd 					
					demond
 					riotsd
					dmiddispforcetowar 							
					"
	;
	#delimit cr			
	
	*Estimating model	
	#delimit ;
	reg milcont_dynamic 
						shock_cuba_1958 
						shock_cuba_1959 
						shock_cuba_1960 
						shock_cuba_1961 
						shock_cuba_1962 
						shock_cuba_1963 
						shock_cuba_1964 
						shock_cuba_1965_ext 
						year1958 
						year1959 
						year1960 
						year1961 
						year1962 
						year1963 
						year1964
						year1965ext 
						cubaally_high_treatg
						$did_controls
						, 
						robust
	;
	#delimit cr		

	*Calculating marginal effects
	parmest, saving("$path\figure10.dta", replace) level(90 95) idstr("llnsoaCOIN")		

	*Preserving data
	preserve
	
		*Loading effects data 
		use "$path\figure10.dta", clear
		
		*Extracting year information
		gen effect=1 if regexm(parm, "shock")
		gen year=regexs(0) if regexm(parm, "[0-9]+") & effect==1
		destring year, replace
		gen time=_n if year!=.
	
		*Graph
		#delimit ;		
		twoway rspike min95 max95 time,
						 lcolor(black) lwidth(*1.15)	
			  || connected estimate time,
						 msize(*1.2) mfcolor(black) mlcolor(black) mlwidth(*.8) mlalign(center) lpattern(shortdash)	lcolor(black)						 
					 yline(0, lpattern(dot) lcolor(gs8))
					 xsize(1.3) ysize(1) 
					 xscale(range(.5 8.5) noextend)
					 yscale(range(-1.5 1.5) noextend titlegap(+1))
					 ylabel(-1.5(.5)1.5, valuelabel nogrid angle(0) labsize(*.85)) 
					 xlabel(1 "-1"
							2 `" "Year of" "Revolution" "(1959)"'
							3 "+1"
							4 "+2"
							5 "+3"
							6 "+4"
							7 "+5"
							8  `" "+6" "and more" "({&ge}1965)"'
							, angle(horizontal) nogrid labsize(*.85) notick labgap(*1.75))
					 xtick(.5(1)8.5)
					 xtitle("", size(*.85))
					 ytitle("Marginal effect on" "military involvement in politics", size(*.85))
					 legend(off
						)
				xline(2, lpattern(dot) lcolor(black))
				plotregion(lcolor(white)) 
				graphregion(color(white) lcolor(white) lalign(outside))	
				; 
		#delimit cr			
		graph export "$path\figure_10.tif", as(tif) replace width(1500)	
	
	*Restoring data
	restore
	
	
	****************************************************************************
	*Figure 11. SOA counterinsurgency training and subsequent political militarization in Panama.
	****************************************************************************	
	
	*Generating cumulative sums for plotting
	egen statebuilding_irregwarfare=rowtotal(soaCOIN_irregularwar soaCOIN_statebuilding)	
	
	*Graph
	#delimit ;
	twoway bar statebuilding_irregwarfare year if country=="Panama" & cuba_win_ind==1, barwidth(.5) lcolor(black) fcolor(black) lwidth(0)
	||	   bar soaCOIN_irregularwar year if country=="Panama" & cuba_win_ind==1, barwidth(.5) lcolor(gs10) fcolor(gs10) lwidth(0)
	||	   connected milcont_dynamic year if country=="Panama" & cuba_win_ind==1, yaxis(2) lwidth(*1.1) mcolor(back) lpattern(solid) lcolor(black)
				 ,
				 xsize(1.25) ysize(1) 
				 xscale(range() noextend titlegap(+2))
				 yscale(range( ) noextend titlegap(+2))
				 yscale(range( ) noextend titlegap(+2) axis(2))
 	             ylabel(, valuelabel nogrid angle(0) labsize(*1) axis(1)) 
 	             ylabel(, valuelabel nogrid angle(0) labsize(*1) axis(2))				 
				 xlabel(1949(5)1969)
				 xticks(1949(1)1969, tlength(*.5))
				 xtitle("Year", size(*1))
				 ytitle("Number of courses", size(*1))
				 ytitle("Military involvement in politics", axis(2) size(*1))
				 xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))
				 legend(order(
						1 "State-building" 				 
						2 "Irregular warfare"					
						)					
					col(1)
					size(*.85) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(lcolor(black))
					position(11) ring(0) bmargin(2 0 0 2)
					)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			; 
	#delimit cr				
	graph export "$path\figure_11.tif", as(tif) replace width(1500)		
	
	
********************************************************************************
*
* Figures in online appendix
*
********************************************************************************	
	
	****************************************************************************
	*Figure SM.2.1. 
	****************************************************************************	
	
	*Loading micro replication dataset 
	use "$path\replication_data_micro.dta", clear
	
	***********************************	
	*Figure SM.2.1. (a)
	***********************************			

	*Preserving data
	preserve 
	
	*Collapsing data for counterinsurgency courses 
	collapse (sum) soaCOIN if soaCOIN==1, by(ctitle)

	*Calculating share of each counterinsurgency course
	egen ctotal = total(soaCOIN)
	gen prop_ctitle = (soaCOIN / ctotal) * 100
	sort prop_ctitle ctitle
	drop if ctitle==""
	
	*Generating y-axis for plotting
	gen yaxis_coin=_n-1
	labmask yaxis_coin, val(ctitle)
	
	*Graph
	#delimit ;
	twoway (bar prop_ctitle yaxis_coin, horizontal lcolor(black) fcolor(gs4) barwidth(0.8)) 
			,
			ysize(1)
			xsize(1.5)
			yscale(range(0 18) noextend titlegap(+2))
			xscale(range(0 20) noextend titlegap(+2))		   
			ylabel(0(1)18, valuelabel angle(horizontal) nogrid labsize(*.9))
			xlabel(0(5)20, labsize(*.9))	
			ytitle("")
			xtitle("Percentage of courses (%)", size(*.9))
			legend(off
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			; 
	#delimit cr	
	graph export "$path\figure_SI21_a.pdf", as(pdf) replace
	
	*Restoring data
	restore
	
	
	***********************************	
	*Figure SM.2.1. (b)
	***********************************		
	
	*Preserving data
	preserve 
	
	*Collapsing data for conventional warfare courses
	collapse (sum) soaNOCOINWARS if soaNOCOINWARS==1, by(ctitle)
	
	*Calculating share of each conventional warfare course	
	egen ctotal = total(soaNOCOINWARS)
	gen prop_ctitle = (soaNOCOINWARS / ctotal) * 100
	sort prop_ctitle ctitle
	
	*Selecting 18 most attended courses (matches number of COIN courses)
	count
	disp r(N)
	gen select=1 if _n > _N-19
	keep if select==1
	
	*Generating y-axis for plotting
	gen yaxis_conv=_n-1	
	labmask yaxis_conv, val(ctitle)	
	
	*Graph
	#delimit ;
	twoway (bar prop_ctitle yaxis_conv, horizontal lcolor(black) fcolor(gs4) barwidth(0.8)) 
			,
			ysize(1)
			xsize(1.5)
			yscale(range(0 18) noextend titlegap(+2))
			xscale(range(0 20) noextend titlegap(+2))		   
			ylabel(0(1)18, valuelabel angle(horizontal) nogrid labsize(*.9))
			xlabel(0(5)20, labsize(*.9))	
			ytitle("")
			xtitle("Percentage of courses (%)", size(*.9))
			legend(off
			)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			; 
	#delimit cr	
	graph export "$path\figure_SI21_b.pdf", as(pdf) replace
	
	*Restoring data
	restore 	
	
	
	****************************************************************************
	*Figure SM.3.1. Officer talent and participation in training at the School of the Americas.
	****************************************************************************	

	*Loading micro replication dataset for Argentine officers
	use "$path\replication_data_micro_argentina.dta", clear
	
	*Graph
	#delimit ;
	twoway (bar mean soa, horizontal fcolor(gs12) lcolor(black) lwidth(0.1) barwidth(.25))
		   (rcap ub lb soa, horizontal lcolor(black) lwidth(*1.25))
			,
			xsize(1.35)
			ysize(1)			
			xscale(range(0 80) noextend titlegap(*+5) )
			yscale(range(.5 3.5) noextend  titlegap(*-10)  reverse )
			xlabel(0(20)100, angle(horizontal) nogrid labgap(+1.5))
			ylabel(
				   1 "Counterinsurgency courses"
				   2 "Conventional warfare courses"
				   3 "No courses"
				   , 
				   nogrid
				   angle(horizontal)
			)
			xtitle("Officers' class ranks")
			ytitle("")
			graphregion(color(white) lcolor(white) lalign(outside) margin(l=5 r=10 t=25)) 			
			legend(off)   
			;
	#delimit cr
	graph export "$path\figure_SI31.pdf", as(pdf) replace
	
		
	****************************************************************************
	*Figure SM.4.1. Checking for broader changes in military priorities.
	****************************************************************************	

	*Loading macro replication dataset
	use "$path\replication_data_macro.dta", clear	
	
	*Preserving data
	preserve
		
	*Collapsing data	
	collapse (count) coin (mean) communistcsa, by(cubaally_high_treatg year)
		
		
	***********************************	
	*Figure SM.4.1. (a)
	***********************************			
		
	*Graph
	#delimit ;
	twoway (connected coin year if cubaally_high_treatg==0, lwidth(*1.1) mlcolor(black) mfcolor(white) lpattern(shortdash) lcolor(black))
		   (connected coin year if cubaally_high_treatg==1, lwidth(*1.1) mcolor(back) lpattern(solid) lcolor(black)) 
		   , 
		   ysize(1)
		   xsize(1.2)
		   xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))  	
		   xscale(range(1949 1969) noextend titlegap(+2)) 
		   xlabel(1949(5)1969)
		   xticks(1949(1)1969, tlength(*.5))
		   xtitle("Year", size(*1))	
		   yscale(range(0 16) noextend)
		   ylabel(0(2)16, nogrid angle(0) labsize(*1)) 		 	   
		   ytitle("Number of insurgencies", size(*1))		   
		   legend( 	
					order(1 "Control group" 2 "Treatment group") 	
					rows(2)	
					size(*.8) 			
					keygap(*0.75) 
					symxsize(*0.4) 
					symysize(*0.5) 
					region(lcolor(black))
					position(5) ring(0) bmargin(0 2.2 2 0)		
		)
		plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
		;
	#delimit cr	
	graph export "$path\figure_SI41_a.pdf", as(pdf) replace	
	
	
	***********************************	
	*Figure SM.4.1. (b)
	***********************************		
	
	*Graph
	#delimit ;
	twoway (connected communistcsa year if cubaally_high_treatg==0, lwidth(*1.1) mlcolor(black) mfcolor(white) lpattern(shortdash) lcolor(black))
		   (connected communistcsa year if cubaally_high_treatg==1, lwidth(*1.1) mcolor(back) lpattern(solid) lcolor(black)) 
		   , 
		   ysize(1)
		   xsize(1.2)
		   xline(1959, lcolor(gs5) lwidth(*1) lpattern(dot))  	
		   xscale(range(1949 1969) noextend titlegap(+2)) 
		   xlabel(1949(5)1969)
		   xticks(1949(1)1969, tlength(*.5))
		   xtitle("Year", size(*1))	
		   yscale(range(-.6 .6) noextend titlegap(-9))
		   ylabel(-.6(.2).6, nogrid angle(0) labsize(*1)) 		 	   
		   ytitle("Activities of leftist anti-regime groups", size(*1))		   
		   legend( 	
					order(1 "Control group" 2 "Treatment group") 	
					rows(2)	
					size(*.8) 			
					keygap(*0.75) 
					symxsize(*0.4) 
					symysize(*0.5) 
					region(lcolor(black))
					position(5) ring(0) bmargin(0 2.2 2 0)		
		)
		plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
		;
	#delimit cr	
	graph export "$path\figure_SI41_b.pdf", as(pdf) replace		
	
	*Restoring data
	restore
	
	
	****************************************************************************
	*Figure SM.4.2. Delayed militarization effect after Cuban Revolution among Batista allies with parallel trends test.
	****************************************************************************	

	*Storing control variables in macros
	#delimit ;
	global did_controls="
					gdpgrowth
					lntroopqual 				
					guerrillad 				
					strikesd 					
					demond
 					riotsd
					dmiddispforcetowar 							
					"
	;
	#delimit cr		
	
	*Estimating model	
	#delimit ;
	reg milcont_dynamic 
						shock_cuba_1954	
						shock_cuba_1955 	
						shock_cuba_1956	
						shock_cuba_1957 
						shock_cuba_1958 
						shock_cuba_1959 
						shock_cuba_1960 
						shock_cuba_1961 
						shock_cuba_1962 
						shock_cuba_1963 
						shock_cuba_1964 
						shock_cuba_1965_ext 
						year1954
						year1955
						year1956						
						year1957 
						year1958 
						year1959 
						year1960 
						year1961 
						year1962 
						year1963 
						year1964
						year1965ext 
						cubaally_high_treatg
						$did_controls
						, 
						robust
	;
	#delimit cr	

	*Calculating marginal effects	
	parmest, saving("$path\FigureSI42.dta", replace) level(90 95) idstr("llnsoaCOIN")	
			
	*Preserving data
	preserve
	
		*Loading data 
		use "$path\FigureSI42.dta", clear
		
		*Extracting year information
		gen effect=1 if regexm(parm, "shock")
		gen year=regexs(0) if regexm(parm, "[0-9]+") & effect==1
		destring year, replace
		gen time=_n if year!=.
		gen time_to_rev=year - 1959
	
		*Graph
		#delimit ;		
		twoway rspike min95 max95 time,
						 lcolor(black) lwidth(*1.15)	
			  || connected estimate time,
						 msize(*1.2) mfcolor(black) mlcolor(black) mlwidth(*.8) mlalign(center) lpattern(shortdash)	lcolor(black)						 
					 yline(0, lpattern(dot) lcolor(gs8))
					 xsize(1.6) ysize(1) 
					 xscale(range(.5 12.5) noextend )
					 yscale(range(-1.5 1.5) noextend titlegap(+1))
					 ylabel(-1.5(.5)1.5, valuelabel nogrid angle(0) labsize(*.85)) 
					 xlabel(
							1 `" "-5" "(1954)"'
							2 "-4"
							3 "-3"
							4 "-2"
							5 "-1"
							6 `" "Year of" "Revolution" "(1959)"'
							7 "+1"
							8 "+2"
							9 "+3"
							10 "+4"
							11 "+5"
							12 `" "+6" "and more" "({&ge}1965)"'
							, angle(horizontal) nogrid labsize(*.85) notick labgap(*1.75))
					 xtick(.5(1)12.5)
					 xtitle("", size(*.85))
					 ytitle("Marginal effect on" "military involvement in politics", size(*.85))
					 legend(off
						)
				xline(6, lpattern(dot) lcolor(black))
				plotregion(lcolor(white)) 
				graphregion(color(white) lcolor(white) lalign(outside))	
				; 
		#delimit cr			
	graph export "$path\figure_SI42.pdf", as(pdf) replace		
	
	*Restoring data
	restore		
	
	
********************************************************************************
*
* Tables in manuscript
*
********************************************************************************

	*Storing control variables in macros
	#delimit ;
	global controls="
					l1_gdpgrowth
					llntroopqual 				
					lguerrillad 				
					lstrikesd 					
					ldemond
 					lriotsd
					ldmiddispforcetoward 			
					ln_yrscoup 					
					"
	;
	#delimit cr	
					
	
	#delimit ;
	global controls_rcheck="
					l1_gdpgrowth
					llntroopqual 				
					lguerrillad 				
					lstrikesd 					
					ldemond
 					lriotsd
					ldmiddispforcetoward 			
					ln_yrscoup 						
					ldemoc_reg
					lfpsimusa
					"
	;
	#delimit cr	
	
	#delimit ;
	global controls_threat="
					l1_gdpgrowth
					llntroopqual 				
					ldmiddispforcetoward 			
					ln_yrscoup 					
					"
	;
	#delimit cr		
	
	#delimit ;
	global controls_extended="
					l1_gdpgrowth
					llntroopqual 				
					lguerrillad 				
					lstrikesd 					
					ldemond
 					lriotsd
					ldmiddispforcetoward 			
					lpart_reg lmil_reg lperson_reg ldemoc_reg 
					coupatt_hist					
					"
	;
	#delimit cr	



	****************************************************************************
	*Table 1. Training content and military involvement in politics.
	****************************************************************************

	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls c2-c19, robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen $controls c2-c19, robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen $controls c2-c19, robust			
	
	
	
********************************************************************************
*
* Tables in online appendix
*
********************************************************************************
	
	
	****************************************************************************
	*Table SM.2.1. Summary statistics.
	****************************************************************************		

	#delimit ;
	sum 
			milcont_dynamic 
			milcont_static
			svolik_military
			svolik_milord
					
			ln_l1_soaCOIN 
			ln_l1_soaNOCOINWARS
			ln_csum3y_soaCOIN 
			ln_csum3y_soaNOCOINWARS
			ln_sum_soaCOIN 
			ln_sum_soaNOCOINWARS
			l1_SOAshare_coingen
			l1_SOAshare_nocoingen

			ln_l1_studentnumCOIN 
			ln_l1_studentnumNOCOIN			
			ln_csum3y_studentnumCOIN 
			ln_csum3y_studentnumNOCOIN			
			ln_sum_studentnumCOIN 
			ln_sum_studentnumNOCOIN			
			l1_share_student_coin
			l1_share_student_nocoin
			
			ln_l1_soaCOIN_milintel 
			ln_l1_soaCOIN_irregularwar 
			ln_l1_soaCOIN_statebuilding 					
			
			ln_soaGEN	
			ln_soaCOIN
			ln_soaNOCOINWARS			
						
			lnumacad
			lperdcls			

			l_csa
			lcommunist_csa 
			lcomneigh_regime
			
			commthreat_low_treatg	
			cubaally_high_treatg
			
			hog_right
			
			lcoin			
			lbkirregular 
			
			lmilpromot
			
			l1ln_usaid_econ
			l1ln_usaid_mil
			lln_us_armssales			
	
			l1_gdpgrowth
			llntroopqual 				
			lguerrillad 				
			lstrikesd 					
			ldemond
			lriotsd
			ldmiddispforcetoward 			

			lfpsimusa
			
			lpart_reg 
			lmil_reg 
			lperson_reg 
			ldemoc_reg

			ln_yrscoup 
			coupatt_hist			
			
			revoltcuba
			
			if cuba_win!=.									
		;
	#delimit cr
	
	
	****************************************************************************
	*Table SM.2.2. Summary statistics (difference-in-differences analysis).
	****************************************************************************		
	
	#delimit ;
	sum 		
				milcont_dynamic 		
				
				shock_post1 
				shock_post2 
				shock_post3 
				shock_post4 
				shock_post5 
				shock_post6 
				
				year1954
				year1955
				year1956						
				year1957 			
				year1958 
				year1959 
				year1960 
				year1961 
				year1962 
				year1963 
				year1964
				year1965ext
				
				cubaally_high_treatg
				
 				if cuba_win!=.
		;
	#delimit cr		
	
	
	****************************************************************************
	*Table SM.3.1. Fixed effects regressions with controls for communist threats.
	****************************************************************************		

	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS lcommunist_csa lcomneigh_regime $controls_threat c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS lcommunist_csa lcomneigh_regime $controls_threat c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS lcommunist_csa lcomneigh_regime $controls_threat c2-c19, robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen lcommunist_csa lcomneigh_regime $controls_threat c2-c19, robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen lcommunist_csa lcomneigh_regime $controls_threat c2-c19, robust			

	
	****************************************************************************
	*Table SM.3.2. Fixed effects regressions with controls for insurgencies.
	****************************************************************************	
	
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS lcoin $controls c2-c19, robust	

	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS lcoin $controls c2-c19, robust		
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS lcoin $controls c2-c19, robust		
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen lcoin $controls c2-c19, robust				
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen lcoin $controls c2-c19, robust				
	
	*Model 6
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS lbkirregular $controls c2-c19, robust		
		
	*Model 7
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS lbkirregular $controls c2-c19, robust	
	
	*Model 8
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS lbkirregular $controls c2-c19, robust		
	
	*Model 9
	reg milcont_dynamic l1_SOAshare_coingen lbkirregular $controls c2-c19, robust				
	
	*Model 10
	reg milcont_dynamic l1_SOAshare_nocoingen lbkirregular $controls c2-c19, robust			
	
	
	****************************************************************************
	*Table SM.3.3. Fixed effects regressions with control for any anti-regime threat.
	****************************************************************************	
	
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS l_csa $controls_threat c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS l_csa $controls_threat c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS l_csa $controls_threat c2-c19, robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen l_csa $controls_threat c2-c19, robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen l_csa $controls_threat c2-c19, robust			

	
	****************************************************************************
	*Table SM.3.4. Results for countries with low threats of communist subversion.
	****************************************************************************		
	
	*Identifying low-threat countries
	groups gwno countryname if commthreat_low_treatg==1	
	
	*Generating fixed effects for low-threat countries
	tab gwno if commthreat_low_treatg==1 & cuba_win!=., gen(c_threalow)
		
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls c_threalow2-c_threalow5 if commthreat_low_treatg==1 , robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls c_threalow2-c_threalow5 if commthreat_low_treatg==1 , robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls c_threalow2-c_threalow5 if commthreat_low_treatg==1 , robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen $controls c_threalow2-c_threalow5 if commthreat_low_treatg==1 , robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen $controls c_threalow2-c_threalow5 if commthreat_low_treatg==1 , robust			
	
	
	****************************************************************************
	*Table SM.3.5. Results for heads of government with rightist ideology.
	****************************************************************************		
	
	*Generating country fixed effects for right-wing leader governments
	tab gwno if hog_right==1 & cuba_win!=., gen(c_leadrigt)

	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls c_leadrigt2-c_leadrigt9 if hog_right==1 , robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls c_leadrigt2-c_leadrigt9 if hog_right==1 , robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls c_leadrigt2-c_leadrigt9 if hog_right==1 , robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen $controls c_leadrigt2-c_leadrigt9 if hog_right==1 , robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen $controls c_leadrigt2-c_leadrigt9 if hog_right==1 , robust			
	
	
	****************************************************************************
	*Table SM.3.6. Fixed effects regressions with control for de facto appointment decisions in military.
	****************************************************************************
	
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS lmilpromot $controls c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS lmilpromot $controls c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS lmilpromot $controls c2-c19, robust	
	
	*Model 4
	reg milcont_dynamic l1_SOAshare_coingen lmilpromot $controls c2-c19, robust			
	
	*Model 5
	reg milcont_dynamic l1_SOAshare_nocoingen lmilpromot $controls c2-c19, robust			
	
	
	****************************************************************************
	*Table SM.3.7. Controlling for different types of US aid.
	****************************************************************************
		
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS l1ln_usaid_econ $controls c2-c19, robust		
	
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS ln_csum3y_usaid_econ $controls c2-c19, robust		
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS ln_sum_usaid_econ $controls c2-c19, robust			
	
	*Model 4
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS l1ln_usaid_econ l1ln_usaid_mil $controls c2-c19, robust			
	
	*Model 5
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS ln_csum3y_usaid_econ ln_csum3y_usaid_mil $controls c2-c19, robust		
	
	*Model 6
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS ln_sum_usaid_econ ln_sum_usaid_mil $controls c2-c19, robust				
	
	*Model 7
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS lln_us_armssales $controls c2-c19, robust	
	
	*Model 8
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS ln_csum3y_us_armssales $controls c2-c19, robust		
	
	*Model 9
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS ln_sum_us_armssales $controls c2-c19, robust	

	
	****************************************************************************
	*Table SM.4.1. Counterinsurgency course content and military involvement in politics (dynamic measure).
	****************************************************************************
	
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN_milintel ln_l1_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 2	
	reg milcont_dynamic ln_l1_soaCOIN_irregularwar ln_l1_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 3
	reg milcont_dynamic ln_l1_soaCOIN_statebuilding ln_l1_soaNOCOINWARS $controls c2-c19, robust
		
	*Model 4
	reg milcont_dynamic ln_csum3y_soaCOIN_milintel ln_csum3y_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 5
	reg milcont_dynamic ln_csum3y_soaCOIN_irregularwar ln_csum3y_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 6
	reg milcont_dynamic ln_csum3y_soaCOIN_statebuilding ln_csum3y_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 7	
	reg milcont_dynamic ln_sum_soaCOIN_milintel ln_sum_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 8
	reg milcont_dynamic ln_sum_soaCOIN_irregularwar ln_sum_soaNOCOINWARS $controls c2-c19, robust
	
	*Model 9	
	reg milcont_dynamic ln_sum_soaCOIN_statebuilding ln_sum_soaNOCOINWARS $controls c2-c19, robust

	*Model 10	
	reg milcont_dynamic l1_share_soaCOIN_milintel l1_SOAshare_nocoingen $controls c2-c19, robust
	
	*Model 11		
	reg milcont_dynamic l1_share_soaCOIN_irregularwar l1_SOAshare_nocoingen $controls c2-c19, robust
		
	*Model 12		
	reg milcont_dynamic l1_share_soaCOIN_statebuilding l1_SOAshare_nocoingen $controls c2-c19, robust	
	
	
	****************************************************************************
	*Table SM.4.2. Domestic dissemination channels of foreign training content.
	****************************************************************************
	
	*Generating interactions
	foreach var of varlist ln_l1_soaCOIN ln_l1_soaNOCOINWARS {
		gen `var'_X_lnumacad = `var' * lnumacad
		gen `var'_X_lperdcls = `var' * lperdcls
	}
		
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_l1_soaCOIN_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad $controls c2-c19, robust	
		
	*Model 3
	reg milcont_dynamic ln_l1_soaNOCOINWARS_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad c2-c19, robust	
		
	*Model 4
	reg milcont_dynamic ln_l1_soaNOCOINWARS_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad $controls c2-c19, robust	
	
	*Model 5
	reg milcont_dynamic ln_l1_soaCOIN_X_lnumacad ln_l1_soaNOCOINWARS_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad c2-c19, robust	
		
	*Model 6
	reg milcont_dynamic ln_l1_soaCOIN_X_lnumacad ln_l1_soaNOCOINWARS_X_lnumacad ln_l1_soaCOIN ln_l1_soaNOCOINWARS lnumacad $controls c2-c19, robust	
	
	*Model 7
	reg milcont_dynamic ln_l1_soaCOIN_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls c2-c19, robust	
		
	*Model 8
	reg milcont_dynamic ln_l1_soaCOIN_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls $controls c2-c19, robust	
		
	*Model 9
	reg milcont_dynamic ln_l1_soaNOCOINWARS_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls c2-c19, robust	
		
	*Model 10
	reg milcont_dynamic ln_l1_soaNOCOINWARS_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls $controls c2-c19, robust	
	
	*Model 11
	reg milcont_dynamic ln_l1_soaCOIN_X_lperdcls ln_l1_soaNOCOINWARS_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls c2-c19, robust	
		
	*Model 12
	reg milcont_dynamic ln_l1_soaCOIN_X_lperdcls ln_l1_soaNOCOINWARS_X_lperdcls ln_l1_soaCOIN ln_l1_soaNOCOINWARS lperdcls $controls c2-c19, robust	
	
	
	****************************************************************************
	*Table SM.4.3. Difference-in-Differences for military involvement in politics (dynamic measure).
	****************************************************************************
	
	*Models without controls
	foreach x of numlist 1/6 {
		reg milcont_dynamic shock_cuba_`x' shock_post`x' cubaally_high_treatg, robust
	}	
	
	*Models with controls	
	foreach x of numlist 1/6 {
		reg milcont_dynamic shock_cuba_`x' shock_post`x' cubaally_high_treatg $did_controls, robust
	}	
	
	
	****************************************************************************
	*Table SM.4.4. Probing anticipatory and lagged effects.
	****************************************************************************
	
	*Model 1
	#delimit ;
	reg milcont_dynamic 
						shock_cuba_1958 
						shock_cuba_1959 
						shock_cuba_1960 
						shock_cuba_1961 
						shock_cuba_1962 
						shock_cuba_1963 
						shock_cuba_1964 
						shock_cuba_1965_ext 
						year1958 
						year1959 
						year1960 
						year1961 
						year1962 
						year1963 
						year1964
						year1965ext 
						cubaally_high_treatg
						, 
						robust
	;
	#delimit cr	
	
	*Model 2
	#delimit ;
	reg milcont_dynamic 
						shock_cuba_1958 
						shock_cuba_1959 
						shock_cuba_1960 
						shock_cuba_1961 
						shock_cuba_1962 
						shock_cuba_1963 
						shock_cuba_1964 
						shock_cuba_1965_ext 
						year1958 
						year1959 
						year1960 
						year1961 
						year1962 
						year1963 
						year1964
						year1965ext 
						cubaally_high_treatg
						$did_controls
						, 
						robust
	;
	#delimit cr		
	
	*Model 3
	#delimit ;
	reg milcont_dynamic 
						shock_cuba_1954	
						shock_cuba_1955 	
						shock_cuba_1956	
						shock_cuba_1957 
						shock_cuba_1958 
						shock_cuba_1959 
						shock_cuba_1960 
						shock_cuba_1961 
						shock_cuba_1962 
						shock_cuba_1963 
						shock_cuba_1964 
						shock_cuba_1965_ext 
						year1954
						year1955
						year1956						
						year1957 
						year1958 
						year1959 
						year1960 
						year1961 
						year1962 
						year1963 
						year1964
						year1965ext 
						cubaally_high_treatg
						$did_controls
						, 
						robust
	;
	#delimit cr	

	
	****************************************************************************
	*Table SM.5.1. Additional control variables.
	****************************************************************************	
		
	*Model 1
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls lfpsimusa c2-c19, robust	
		
	*Model 2
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls lfpsimusa c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls lfpsimusa c2-c19, robust	

	*Model 4
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls lpart_reg lmil_reg lperson_reg ldemoc_reg c2-c19, robust	
		
	*Model 5
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls lpart_reg lmil_reg lperson_reg ldemoc_reg c2-c19, robust	
	
	*Model 6
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls lpart_reg lmil_reg lperson_reg ldemoc_reg c2-c19, robust	
	
	*Model 7
	reg milcont_dynamic ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls_extended c2-c19, robust	
		
	*Model 8
	reg milcont_dynamic ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls_extended c2-c19, robust	
	
	*Model 9
	reg milcont_dynamic ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls_extended c2-c19, robust	
	
	
	****************************************************************************
	*Table SM.5.2. Student numbers and military involvement in politics (dynamic measure).
	****************************************************************************	
	
	*Model 1
	reg milcont_dynamic ln_l1_studentnumCOIN ln_l1_studentnumNOCOIN $controls c2-c19, robust		
		
	*Model 2
	reg milcont_dynamic ln_csum3y_studentnumCOIN ln_csum3y_studentnumNOCOIN $controls c2-c19, robust	
	
	*Model 3
	reg milcont_dynamic ln_sum_studentnumCOIN ln_sum_studentnumNOCOIN $controls c2-c19, robust	
	
	*Model 4
	reg milcont_dynamic l1_share_student_coin $controls c2-c19, robust				
	
	*Model 5
	reg milcont_dynamic l1_share_student_nocoin $controls c2-c19, robust				
	
	
	****************************************************************************
	*Table SM.5.3. Training content and military involvement in politics (Binary Svolik measure).
	****************************************************************************	
	
	*Model 1
	reg svolik_military ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls c2-c19, robust		
		
	*Model 2
	reg svolik_military ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls c2-c19, robust		
	
	*Model 3
	reg svolik_military ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls c2-c19, robust		
	
	*Model 4
	reg svolik_military l1_SOAshare_coingen $controls c2-c19, robust			
	
	*Model 5
	reg svolik_military l1_SOAshare_nocoingen $controls c2-c19, robust			
	
	
	****************************************************************************
	*Table SM.5.4. Training content and military involvement in politics (Categorical Svolik measure).
	****************************************************************************		
	
	*Model 1
	reg svolik_milord ln_l1_soaCOIN ln_l1_soaNOCOINWARS $controls c2-c19, robust		
		
	*Model 2
	reg svolik_milord ln_csum3y_soaCOIN ln_csum3y_soaNOCOINWARS $controls c2-c19, robust			
	
	*Model 3
	reg svolik_milord ln_sum_soaCOIN ln_sum_soaNOCOINWARS $controls c2-c19, robust		
	
	*Model 4
	reg svolik_milord l1_SOAshare_coingen $controls c2-c19, robust	
	
	*Model 5
	reg svolik_milord l1_SOAshare_nocoingen $controls c2-c19, robust
	

********************************************************************************	
*
*
*	
********************************************************************************		
	
	*Closing graph windows
	graph close _all 
	
	*Clearing data
	clear all
	
	*End recording log file
	log close	
